package com.itheima.tlias08_14.utils;

import lombok.Data;

import java.util.HashMap;

@Data
public class ResultUtil {
    private int code;
    private String msg;
    private Object data;

    public static ResultUtil success() {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(1);
        resultUtil.setMsg("success");
        //data不赋值  默认为null
        return resultUtil;
    }

    /**
     *
     * @param message 自定义输出信息
     * @return
     */
    public static ResultUtil success(String message) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(1);
        resultUtil.setMsg(message);
        //data不赋值  默认为null
        return resultUtil;
    }

    public static ResultUtil success(Object data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(1);
        resultUtil.setMsg("success");
        resultUtil.setData(data);
        return resultUtil;
    }
//    public static ResultUtil success(String data) {
//        ResultUtil resultUtil = new ResultUtil();
//        resultUtil.setCode(1);
//        resultUtil.setMsg("success");
//        resultUtil.setData(data);
//        return resultUtil;
//    }

    public static ResultUtil failure() {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(0);
        resultUtil.setMsg("false");
        //data不赋值  默认为null
        return resultUtil;
    }

    /**
     *
     * @param message 自定义输出信息
     * @return
     */
    public static ResultUtil failure(String message) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(0);
        resultUtil.setMsg(message);
        //data不赋值  默认为null
        return resultUtil;
    }

    public static ResultUtil failure(Object data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(0);
        resultUtil.setMsg("false");
        resultUtil.setData(data);
        return resultUtil;
    }

}
